package org.example.service.impl;

import org.example.aop.ShardingForSchedule;
import org.example.datasource.TargetDataSource;
import org.example.domain.JkCustomer;
import org.example.mapper.JkCustomerMapper;
import org.example.service.IShardingJDBCService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class IShardingJDBCServiceImpl implements IShardingJDBCService {

    @Resource
    private JkCustomerMapper jkCustomerMapper;

    @Override
    public JkCustomer selectByPrimaryKey(Long customerId) {
        return jkCustomerMapper.selectByPrimaryKey(customerId);
    }

    @Override
    @ShardingForSchedule
    public void testAop() {
        System.out.println("testAop");
    }

    @Override
    @Transactional()
    @TargetDataSource("shardingMaster")
    public void testShardingMaster() {
        jkCustomerMapper.selectByPrimaryKey(1L);
    }
}
